/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "HorarioXLocal")
@NamedQueries({
    @NamedQuery(name = "Horarioxlocal.findAll", query = "SELECT h FROM Horarioxlocal h"),
    @NamedQuery(name = "Horarioxlocal.findByIdLocal", query = "SELECT h FROM Horarioxlocal h WHERE h.horarioxlocalPK.idLocal = :idLocal"),
    @NamedQuery(name = "Horarioxlocal.findByIdHorarioT", query = "SELECT h FROM Horarioxlocal h WHERE h.horarioxlocalPK.idHorarioT = :idHorarioT"),
    @NamedQuery(name = "Horarioxlocal.findByEstado", query = "SELECT h FROM Horarioxlocal h WHERE h.estado = :estado")})
public class Horarioxlocal implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HorarioxlocalPK horarioxlocalPK;
    @Column(name = "Estado")
    private Integer estado;
    @JoinTable(name = "HorarioXPersonal", joinColumns = {
        @JoinColumn(name = "Horario_Por_Local_IdLocal", referencedColumnName = "IdLocal"),
        @JoinColumn(name = "Horario_Por_Local_IdHorarioT", referencedColumnName = "IdHorarioT")}, inverseJoinColumns = {
        @JoinColumn(name = "Personal_IdPersonal", referencedColumnName = "IdPersonal")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<Personal> personalList;
    @JoinColumn(name = "IdLocal", referencedColumnName = "IdLocal", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Local local;
    @JoinColumn(name = "IdHorarioT", referencedColumnName = "IdHorarioT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private HorarioTrabajo horarioTrabajo;

    public Horarioxlocal() {
    }

    public Horarioxlocal(HorarioxlocalPK horarioxlocalPK) {
        this.horarioxlocalPK = horarioxlocalPK;
    }

    public Horarioxlocal(int idLocal, int idHorarioT) {
        this.horarioxlocalPK = new HorarioxlocalPK(idLocal, idHorarioT);
    }

    public HorarioxlocalPK getHorarioxlocalPK() {
        return horarioxlocalPK;
    }

    public void setHorarioxlocalPK(HorarioxlocalPK horarioxlocalPK) {
        this.horarioxlocalPK = horarioxlocalPK;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public List<Personal> getPersonalList() {
        return personalList;
    }

    public void setPersonalList(List<Personal> personalList) {
        this.personalList = personalList;
    }

    public Local getLocal() {
        return local;
    }

    public void setLocal(Local local) {
        this.local = local;
    }

    public HorarioTrabajo getHorarioTrabajo() {
        return horarioTrabajo;
    }

    public void setHorarioTrabajo(HorarioTrabajo horarioTrabajo) {
        this.horarioTrabajo = horarioTrabajo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (horarioxlocalPK != null ? horarioxlocalPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Horarioxlocal)) {
            return false;
        }
        Horarioxlocal other = (Horarioxlocal) object;
        if ((this.horarioxlocalPK == null && other.horarioxlocalPK != null) || (this.horarioxlocalPK != null && !this.horarioxlocalPK.equals(other.horarioxlocalPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.Horarioxlocal[ horarioxlocalPK=" + horarioxlocalPK + " ]";
    }
    
}
